// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) 
// Source File Name:   CurrencyDAO.java

package com.nervytech.tutorcruise.db.dao.mysql.impl;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.LinkedHashMap;
import java.util.Map;

import javax.sql.DataSource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.ResultSetExtractor;
import org.springframework.jdbc.core.support.JdbcDaoSupport;
import org.springframework.stereotype.Repository;

import com.nervytech.tutorcruise.db.dao.interfaces.ICurrencyDAO;

@Repository("currencyDAO")
public class CurrencyDAO extends JdbcDaoSupport implements ICurrencyDAO {

	@Autowired
	CurrencyDAO(DataSource dataSource) {
		setDataSource(dataSource);
	}

	public Map<Integer, String> getCurrencyMap() {
		final Map<Integer, String> catsMap = new LinkedHashMap<Integer, String>();
		String selectCatsQuery = "SELECT * FROM CURRENCY";
		logger.debug((new StringBuilder("Select user Query : ")).append(
				selectCatsQuery).toString());
		getJdbcTemplate().query(selectCatsQuery, new ResultSetExtractor<Object>() {

			public Object extractData(ResultSet rs) throws SQLException,
					DataAccessException {
				for (; rs.next(); catsMap.put(
						Integer.valueOf(rs.getInt("currency_id")),
						rs.getString("code")))
					;
				return null;
			}

		});
		return catsMap;
	}
}
